set more off

/* This file replicates the results in Table 5, Chegere, Eggert & Söderbom (CES) */ 

/*cd "C:\xxx....*/

discard 
clear all

use "CES2019_data.dta" 

keep if wave==1 & est_sample==1

/* this program uses wild bootstrap procedure for statistical tests */
prog def btf 
boottest {bagstreatment}{traintreatment}{bagstreatment=traintreatment}{sex}{age}{schooling}{activeworkers}{wealth}{maizeexperienceyears}{trained}, cluster (villagecode) reps(999) seed (906453) nogr
end


/* Table 5: Impact on maize protectants use and cost of protection (note: infererence is not based on the std errors reported here)  */

foreach yvar in usedprotectants Spraying Trappoison protcostperton{
reg `yvar' bagstreatment traintreatment sex age schooling activeworkers wealth maizeexperienceyears trained, cluster(villagecode)
btf
}

/* Obtain p-values by means of randomised inference ("randomization-t randomized p-value") for treatment effects */
foreach yvar in usedprotectants Spraying Trappoison protcostperton{
randcmd ((bagstreatment traintreatment) reg `yvar' bagstreatment traintreatment sex age schooling activeworkers wealth maizeexperienceyears trained, cluster(villagecode)), treatvars(bagstreatment traintreatment)  groupvar(village)
}

exit